package com.aceitunaproject.clientinterface;

import com.aceitunaproject.clientinterface.eventadapters.AceitunaConnectionEventsHandler;
import com.aceitunaproject.clientinterface.eventregistering.AceitunaAllEventsHandler;
import com.aceitunaproject.clientinterface.eventregistering.ChatMessageReceivedHandler;
import com.aceitunaproject.clientinterface.eventregistering.MapAreaRefreshHandler;
import com.aceitunaproject.clientinterface.eventregistering.RuleViolationEventReceivedHandler;
import com.aceitunaproject.shared.message.Message;

/**
 *  
 * Interface for event handling and sending of messages to the Aceituna Server
 * 
 * @author Federico Bergstein
 */
public interface AceitunaClientInterface {
	
	
	
	// TODO: add event deregistration.(may need some way of identifying handlers)
	
	/**
	 * Overloaded method to register an object to be notified of events 
	 * @param handler
	 */
	public void registerToEvent(ChatMessageReceivedHandler handler);
	public void registerToEvent(MapAreaRefreshHandler handler);
	public void registerToEvent(RuleViolationEventReceivedHandler handler);
	public void registerToEvent(AceitunaAllEventsHandler handler);
	
	
	/**
	 * registers an object to notify connection events
	 * @param handler the object to notify
	 */
	void registerForConnectionEvents(AceitunaConnectionEventsHandler handler);
	
		
	/**
	 * Sends a message to the server
	 * 
	 * @param message the message to send
	 */
	public void sendMessage(Message message);
		
	
	
	/** the name of the player*/
	public String getPlayer();
	
	//Message encapsulation
	
	/**
	 * Encapsulates the MoveUnitRequest message
	 */
	public void moveUnit(Long unitID,int x,int y);
	
	/**
	 * Encapsulates the AttackUnitRequest message
	 */
	public void attackUnit(Long attackingUnitID,Long enemyUnitID);
	
	/**
	 * Encapsulates the BuildSettlementRequest message
	 */
	public void buildSettlement(Long unitID,String name,int x,int y);
	
	/**
	 * Encapsulates the BuildInstallationRequest message
	 */
	public void buildInstallation(Long unitID, String name, int x, int y,
			String installationType);
	
	/**
	 * Encapsulates the recruitUnitRequest message
	 */
	public void recruitUnit(Long settlementID, String name, int persons);
	
	/**
	 * Encapsulates the MapRefreshRequest message
	 */
	public void requestMapRefresh();
	
	/**
	 * Processes a message that the listener received from the server
	 * @param deserializedMessage the received message, deserialized from its ByteBuffer original form
	 */
	public void processMessage(Message deserializedMessage);
	
	/**
	 * Called when the Listener logs in
	 */
	public void loggedIn();
	/**
	 * Called when the Listener attempts to login and fails
	 */
	public void loginFailed(String arg0);
	/**
	 * Called when the Listener reconnects
	 */
	public void reconnected();
	/**
	 * Called when the Listener is reconnecting
	 */
	public void reconnecting();
	/**
	 * Called when the Listener gets disconnected 
	 */
	public void disconnected(boolean arg0, String arg1);
	
	/**
	 * Login to the server
	 */
	 public void login();
	
	/**
	 * Logout from the server
	 */
	void logout();
	public void setPlayer(String userName);
	
	
	

}
